<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 350px;
            margin: 100px auto;
        }
        .p{
            display: inline-block;
            font-size: 13px;
            color:silver;
            padding-left: 20px;
            background: url(/跟着狂神/img/正确.png) no-repeat;
            background-size: 17px 17px;
        }
       .ps{
        color: red;
        background: url(/跟着狂神/img/错误.png)no-repeat;
        background-size: 17px 17px;
       }
       .pss{
        color: rgb(11, 223, 64);
        background: url(/跟着狂神/img/正确.png)no-repeat;
        background-size: 17px 17px;
       }
    </style>
</head>
<body>
    <div>
        密码: <input type="password" class="paw">
        <p class="p">请输入6-16位密码</p>
    </div>
    <script>
        var p=document.querySelector('p')
        var txt=document.querySelector('input')
     txt.onblur=function(){
        if(this.value.length<6 || this.value.length>16){
           p.className='p ps' 
           p.innerHTML='请输入6-16位数...'
        }else{
           p.className='p pss' 
           p.innerHTML='输入正确..'
        }
     }
    </script>
</body>
</html>